package ch05_类与对象;

public class FinalAndStaticDemo {
	static final int MIN=1;
	final static int MAX=10;
	int m;
	static int n=5;
	private static FinalAndStaticDemo demo1;
	static {
		System.out.print("执行静态语句块1.");
		demo1=new FinalAndStaticDemo(10);
	}
	FinalAndStaticDemo(int m){
		this.m=m;
	}
	private void m1() {
		System.out.print("执行方法m1.");
		m2();
		m3();
	}
	private static void m2() {
		System.out.print("执行方法m2.");
	}
	private void m3() {
		System.out.print("执行方法m3.");
		final FinalAndStaticDemo d=new FinalAndStaticDemo(5);
		//d=new FianlAndStaticDemo(5);语法错误//
		d.m=40;
	}
	public static void main(String[] args) {
		m2();
		FinalAndStaticDemo demo2=new FinalAndStaticDemo(20);
		demo2.m1();
		demo2.m2();
		demo1.m=demo1.m+1;
		System.out.print("\ndemo1.m="+demo1.m+"\t");
		System.out.print("demo2.m="+demo2.m);
		demo1.n=demo1.n+1;
		System.out.print("\ndemo1.n="+demo1.n+"\t");
		System.out.print("demo2.n="+demo2.n);
		
	}
	static {
		System.out.print("执行静态语句块2.\n");
	}
}
